﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace Itop.KSRY {
    public partial class frmStart : XtraForm {
        Rectangle fontRect = Rectangle.Empty;
        Rectangle startRect = Rectangle.Empty;
        
        public frmStart() {
            InitializeComponent();
            fontRect = label1.Bounds;
            startRect = label2.Bounds;
            label2.Hide();
            label1.Hide();
            pictureBox1.Paint += new PaintEventHandler(pictureBox1_Paint);
            pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove);
            pictureBox1.MouseClick += new MouseEventHandler(pictureBox1_MouseClick);
            this.KeyDown += new KeyEventHandler(pictureBox1_KeyDown);
        }
        protected override void OnShown(EventArgs e) {
            base.OnShown(e);


        }
        void pictureBox1_KeyDown(object sender, KeyEventArgs e) {
            if (e.KeyCode == Keys.O && e.Control) {
                frmMain dlg = new frmMain();
                dlg.FormClosed+=new FormClosedEventHandler(dlg_FormClosed);
                dlg.Show();
                this.Hide();
            }
        }
        
        void pictureBox1_MouseClick(object sender, MouseEventArgs e) {
            if (Cursor == Cursors.Hand) {
                frmKs dlg = new frmKs();
                dlg.WindowState = FormWindowState.Maximized;
                dlg.FormClosed += new FormClosedEventHandler(dlg_FormClosed);
                this.Hide();
                dlg.Show();
                
            }
        }

        void dlg_FormClosed(object sender, FormClosedEventArgs e) {
            this.Show();
        }

        void pictureBox1_MouseMove(object sender, MouseEventArgs e) {
            if (startRect.Contains(e.Location))
                Cursor = Cursors.Hand;
            else
                Cursor = Cursors.Default;
        }
        protected override void OnMouseMove(MouseEventArgs e) {
            base.OnMouseMove(e);
            if (startRect.Contains(e.Location))
                Cursor = Cursors.Hand;
            else
                Cursor = Cursors.Default;
        }
        void pictureBox1_Paint(object sender, PaintEventArgs e) {
            e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
            e.Graphics.DrawString(Properties.Settings.Default.ksInfo, Properties.Settings.Default.ksInfoFont, Brushes.Black,fontRect);
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
            this.Close();
        }
        
    }
}
